Sorry I have no Idea on how to do this. Thanks for the information.
DB Win
DBE List
string arr[] = { "GHI","DEF", "ABC"}
int i = sizeof(arr)
void test(DBE Elem, int j)
{
int i = getSortColumn(List)
setSortColumn(List, i)
print i"\n"
}
Win = centered("Test")
List = listView(Win, listViewOptionSortText, 200, 10, arr, i)
realize(Win)
set(List, test)
insertColumn(List, 0, "Testing Sorting", 175, iconNone)
show(Win)
SystemAdmin - Tue Apr 06 12:21:22 EDT 2010 |
Re: How to Sort by Selected Column
Yes, the listView must have option listViewOptionSortText.
//*******************
int clbkfDbeLvSortFunction(string s1, s2)
{ // Standard sort function when defining a column as sortable.
// Developers Note: Some code if added herein will cause DXL exception Violations.
// Don't understand why, but this function needs to be kept as-is.
int Result
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
elseif (s1 < s2) Result = -1
else{} // all cases covered
return(Result)
} // end clbkfDbeLvSortFunction()
set(List, ColNum, clbkfDbeLvSortFunction)
|
Re: How to Sort by Selected Column llandale - Wed Apr 07 14:34:52 EDT 2010
Yes, the listView must have option listViewOptionSortText.
//*******************
int clbkfDbeLvSortFunction(string s1, s2)
{ // Standard sort function when defining a column as sortable.
// Developers Note: Some code if added herein will cause DXL exception Violations.
// Don't understand why, but this function needs to be kept as-is.
int Result
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
elseif (s1 < s2) Result = -1
else{} // all cases covered
return(Result)
} // end clbkfDbeLvSortFunction()
set(List, ColNum, clbkfDbeLvSortFunction)
Louie, applying your code to his example and changing the sort function I do not get any exceptions on DOORS 8.2. Regards, Mathias
DB Win
DBE List
string arr[] = { "GHI","DEF", "ABC"}
int i = sizeof(arr)
int clbkfDbeLvSortFunction(string s1, s2) {
int Result
print "Crash me"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
else Result = -1
return(Result)
} // end clbkfDbeLvSortFunction()
Win = centered("Test")
List = listView(Win, listViewOptionSortText, 200, 10, arr, i)
realize(Win)
insertColumn(List, 0, "Testing Sorting", 175, iconNone)
set(List, 0, clbkfDbeLvSortFunction)
show(Win)
|
Re: How to Sort by Selected Column llandale - Wed Apr 07 14:34:52 EDT 2010
Yes, the listView must have option listViewOptionSortText.
//*******************
int clbkfDbeLvSortFunction(string s1, s2)
{ // Standard sort function when defining a column as sortable.
// Developers Note: Some code if added herein will cause DXL exception Violations.
// Don't understand why, but this function needs to be kept as-is.
int Result
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
elseif (s1 < s2) Result = -1
else{} // all cases covered
return(Result)
} // end clbkfDbeLvSortFunction()
set(List, ColNum, clbkfDbeLvSortFunction)
I used this function and is amazing but I have the following issues:
DB Win
DBE List
string arr[] = { "GHI","aEF", "ABC"}
int i = sizeof(arr)
int clbkfDbeLvSortFunction(string s1, s2) {
int Result
print "Crash me"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
else Result = -1
return(Result)
} // end clbkfDbeLvSortFunction()
Win = centered("Test")
List = listView(Win, listViewOptionSortText, 200, 10, arr, i)
realize(Win)
insertColumn(List, 0, "Testing Sorting", 175, iconNone)
set(List, 0, clbkfDbeLvSortFunction)
show(Win)
setSortColumn
Declaration
void setSortColumn(DBE listView,
int columnIndex)
Operation
Sets the column to be sorted to the column specified by columnIndex. This works only for list views.
|
Re: How to Sort by Selected Column SystemAdmin - Thu Apr 08 07:26:54 EDT 2010
I used this function and is amazing but I have the following issues:
DB Win
DBE List
string arr[] = { "GHI","aEF", "ABC"}
int i = sizeof(arr)
int clbkfDbeLvSortFunction(string s1, s2) {
int Result
print "Crash me"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
else Result = -1
return(Result)
} // end clbkfDbeLvSortFunction()
Win = centered("Test")
List = listView(Win, listViewOptionSortText, 200, 10, arr, i)
realize(Win)
insertColumn(List, 0, "Testing Sorting", 175, iconNone)
set(List, 0, clbkfDbeLvSortFunction)
show(Win)
setSortColumn
Declaration
void setSortColumn(DBE listView,
int columnIndex)
Operation
Sets the column to be sorted to the column specified by columnIndex. This works only for list views.
Hey Douglas,
DB Win
DBE List
string arr[] = { "GHI","special","aEF", "ABC", "test", "Tool", "special","abc"}
int i = 4
int clbkfDbeLvSortFunction(string s1, s2) {
int Result
print "Comparing " s1 " and " s2 "\n"
// these lines will make the string "special" stick to the top when sorted
if (lower s1 == "special") return -1
if (lower s2 == "special") return 1
// otherwise do case independent sorting
if (lower s1 == lower s2) Result = 0
elseif (lower s1 > lower s2) Result = 1
else Result = -1
return(Result)
}
// sort the second column
void bt1Callback (DBE) { setSortColumn (List, 1) }
// sort the second column
void bt0Callback (DBE) { setSortColumn (List, 0) }
Win = centered("Test")
List = listView(Win, listViewOptionSortText, 200, 10, arr, i)
button(Win, "Sort 1st", bt0Callback)
beside Win
button(Win, "Sort 2nd", bt1Callback)
realize(Win)
// Two columns now
insertColumn(List, 0, "Testing Sorting", 85, iconNone)
insertColumn(List, 1, "2nd Column", 85, iconNone)
for i in 4:7 do set(List, i-4, 1,arr[i] )
set(List, 0, clbkfDbeLvSortFunction)
set(List, 1, clbkfDbeLvSortFunction)
// we start unsorted ...
show(Win)
|
Re: How to Sort by Selected Column SystemAdmin - Thu Apr 08 07:26:54 EDT 2010
I used this function and is amazing but I have the following issues:
DB Win
DBE List
string arr[] = { "GHI","aEF", "ABC"}
int i = sizeof(arr)
int clbkfDbeLvSortFunction(string s1, s2) {
int Result
print "Crash me"
if (s1 == s2) Result = 0
elseif (s1 > s2) Result = 1
else Result = -1
return(Result)
} // end clbkfDbeLvSortFunction()
Win = centered("Test")
List = listView(Win, listViewOptionSortText, 200, 10, arr, i)
realize(Win)
insertColumn(List, 0, "Testing Sorting", 175, iconNone)
set(List, 0, clbkfDbeLvSortFunction)
show(Win)
setSortColumn
Declaration
void setSortColumn(DBE listView,
int columnIndex)
Operation
Sets the column to be sorted to the column specified by columnIndex. This works only for list views.
The sort function itself was very touchy, sometimes when I added something benign to it, it would not work. I don't recall the exact details, but it seems to me that adding a line caused very strange behavior. Not all changes caused exceptions; perhaps it was just inside the if-elseif- statements. Looking inside the doors.exe I see that this function can actually have any type of parameters, not just strings, and I'm suspecting that is the cause of errors. ((Mindlessly digressing: this seems similar to Skip Lists that must be defined with createString() to handle string Keys that may be originally constants OR variables...the 'key' in Skips can be of any type also... Perhaps my testing was with constant arrays, rather than arrays populated with variable values...)) I don't recall the details of the sorting, you can experiment and figure that out. A < a; A < z? I imagine if you tweak the sort function changing the > sign to <, it should do a reverse sort. If you want a clever toggle sort (like all other GUI columns), you'd have to change the sort function to cleverly remember ListView DBE and Column and how its currently sorted (if at all), and figure out to do a > or < return. However, like I said, the function is tempermental and I doubt you will succeed. The setSortColumn() function will perform a sort on the column, so long as its set up originally for sorting.
|